#pragma once
#include <vector>
#include <string>

class Fluid {
public:
    struct Component {
        std::string name;
        double moles;
        double molWeight;  // g/mol
        double density;    // g/cm3
    };

    struct PVTPoint {
        double pressure;    // Pa
        double temperature; // K
        double gasDensity;  // kg/m3 (ROG)
        double oilDensity;  // kg/m3 (ROHL)
        double waterDensity;// kg/m3 (ROWT)
        // 其他物性参数...
    };

    Fluid(const std::string& pvtFile);
    
    // 根据压力和温度获取物性
    double getGasDensity(double p, double T) const;
    double getOilDensity(double p, double T) const;
    double getWaterDensity(double p, double T) const;
    double getGasViscosity(double p, double T) const;
    double getOilViscosity(double p, double T) const;
    double getWaterViscosity(double p, double T) const;

    // 获取临界参数
    double getCriticalPressure() const { return criticalPressure_; }
    double getCriticalTemperature() const { return criticalTemperature_; }

    // 获取物性参数
    double getSpecificHeat(double p, double T) const;
    double getLatentHeat(double p, double T) const;

    // 添加焓和比热容相关函数
    double getGasEnthalpy(double p, double T) const;
    double getLiquidEnthalpy(double p, double T) const;
    double getDropletEnthalpy(double p, double T) const;
    
    double getGasHeatCapacity(double p, double T) const;
    double getLiquidHeatCapacity(double p, double T) const;
    double getDropletHeatCapacity(double p, double T) const;

private:
    std::vector<Component> components_;
    std::vector<PVTPoint> pvtData_;
    void loadPVTFile(const std::string& filename);
    // 插值函数
    double interpolate(double p, double T, int propertyIndex) const;

    // 临界参数
    double criticalPressure_;    // 临界压力 [Pa]
    double criticalTemperature_; // 临界温度 [K]
}; 